package com.youngball.business.dao.redis.task;

import org.junit.Test;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

import java.sql.Timestamp;
import java.util.Date;

/**
 * Created by liaopingzhu on 2017/1/12.
 */
public class TestRedis {

    public static final String CHANNEL_NAME = "MyChannel";

    public static final String REDIS_HOST = "127.0.0.1";
    public static final int REDIS_PORT = 6379;

    //    private final static Logger LOGGER = Logger.getLogger(Program.class);
    private final static JedisPoolConfig POOL_CONFIG = new JedisPoolConfig();
    private final static JedisPool JEDIS_POOL =
            new JedisPool(POOL_CONFIG, REDIS_HOST, REDIS_PORT, 0);


    public static void main(String[] args) {
        final Jedis jedis = JEDIS_POOL.getResource();
        Date date = new Date();
        Timestamp timestamp = new Timestamp(date.getTime());
        System.out.println(timestamp.getTime());
        System.out.println(date.getTime());
        long time = gettimeStap();
        System.err.println(time / 1000);
//        jedis.set("ceshi1", "kkk");
        jedis.expireAt("notify", time / 1000);
//        jedis.expire("dingshi",3);

    }

    public static long gettimeStap(){
        Timestamp ts = new Timestamp(System.currentTimeMillis());
        String tsStr = "2017-01-12 21:56:00";
        try {
            ts = Timestamp.valueOf(tsStr);
            System.out.println("======="+ts.getTime());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ts.getTime();
    }

    @Test
    public void test1(){
        Timestamp ts = new Timestamp(1484202955);
        Date date = new Date();
        try {
            date = ts;
            System.out.println(date);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
